package com.icode.utils;

import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DBConnection {
	private static Connection conn;
	
	public static Connection getConnection(){
		if(conn == null){
			try {
				// Step 1: Reg driver
				Class.forName("com.microsoft.sqlserver.jdbc.SQLServerDriver");
				// Step 2: Create connection
				conn = DriverManager.getConnection("jdbc:sqlserver://localhost:1433;databaseName=touristAttraction","sa","123456");
			} catch (SQLException e) {
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				e.printStackTrace();
			}
		}
		return conn;
	}
}
